<template>
  <div class="cycle-page">
    <Card shadow>
      <div class="cycle-box">
        <Tabs :value="name1">
          <TabPane :label="item.label" :name="item.value" v-for="(item, index) in tabDatas" :key="index"></TabPane>
          <div slot="extra">
            <Row type='flex' span="12" style="width: 300px" justify='space-around' :gutter='20'>
                <Col flex span="12" class="input">
                  <Input v-model="inputValue" placeholder="用户名/设备名称/设备编号" style="width: 180px" />
                </Col>
            </Row>
          </div>
        </Tabs>
      </div>
      <div class="cycle-card-box">
        <div class="card-item">
          <div class="header">
            <div class="left">
              <div>2019.3.29-4.07</div>
              <div>美奇颐健安 设备ID:2323333232</div>
            </div>
            <div class="right">
              查看详情
            </div>
          </div>
          <div class="middle">
           <div class="middle-box" v-for="(item, index) in 3" :key="index">
              <div class="num">100 <span>%</span> </div>
              <div class="hanyu">达标率</div>
           </div>
          </div>
          <div class="bottom">
            <ChartLine></ChartLine>
          </div>
        </div>
      </div>
    </Card>
  </div>
</template>

<script>
import Tables from '_c/tables'
import { ChartXueLine, ChartLine } from '_c/charts'
import { getTableData } from '@/api/data'
import Icons from '_c/icons'

export default {
  name: 'cycle_page',
  components: {
    Tables,
    ChartXueLine,
    ChartLine,
    Icons
  },
  data () {
    return {
      inputValue: '',
      name1: '0',
      time1: '3分钟前更新  14:35',
      tabDatas: [
        { label: '动态血糖周期', value: '0' },
        { label: '指尖血糖周期', value: '1' }
      ],
      columns: [
        { title: 'Name', key: 'name', sortable: true },
        { title: 'Email', key: 'email', editable: true },
        { title: 'Create-Time', key: 'createTime' },
        {
          title: 'Handle',
          key: 'handle',
          options: ['delete'],
          button: [
            (h, params, vm) => {
              return h('Poptip', {
                props: {
                  confirm: true,
                  title: '你确定要删除吗?'
                },
                on: {
                  'on-ok': () => {
                    vm.$emit('on-delete', params)
                    vm.$emit('input', params.tableData.filter((item, index) => index !== params.row.initRowIndex))
                  }
                }
              }, [
                h('Button', '自定义删除')
              ])
            }
          ]
        }
      ],
      tableData: []
    }
  },
  methods: {
    handleDelete (params) {
      console.log(params)
    },
    exportExcel () {
      this.$refs.tables.exportCsv({
        filename: `table-${(new Date()).valueOf()}.csv`
      })
    }
  },
  mounted () {
    // getTableData().then(res => {
    //   this.tableData = res.data
    // })
  }
}
</script>

<style lang='less'>
.size {
  width: 100%;
  height: 100%;
}
  .ivu-tabs {
    overflow: inherit !important;
  }
  .ivu-tabs-nav-right {
    position: relative;
  }
  .ivu-tabs-tab-active {
    color: #16CCA6 !important;
  }
  .ivu-tabs-tab-focused {

  }
  .ivu-tabs-ink-bar {
    background-color: #16CCA6;
  }
.cycle-page {
  width: 100%;
}
.cycle-card-box {
  width: 100%;
  .card-item {
    width: 343px;
    height: 324px;
    background: #FFFFFF;
    border-radius: 6px;
    border: 1px solid #E6E9F0;
    padding: 10px;
    .header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      .left {
        height: 40px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        div {
          font-size: 12px;
          font-family: PingFang-SC-Regular, PingFang-SC;
          font-weight: 400;
          color: #242424;
          line-height: 14px;
        }
      }
      .right {
        width: 88px;
        height: 28px;
        background: #16CCA6;
        border-radius: 12px;
        text-align: center;
        line-height: 28px;
        font-size: 12px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #FFFFFF;
      }
    }
    .middle {
      display: flex;
      margin-top: 10px;
      border-top: 1px solid #ccc;
      padding-top: 10px;
      .middle-box {
        flex: 1;
        margin-right: 10px;
        border-radius: 7px;
        height: 104px;
        text-align: center;
        .num {
          font-size: 28px;
          font-family: PingFang-SC-Heavy, PingFang-SC;
          font-weight: 800;
          color: #FFFFFF;
          text-align: center;
          margin-top: 10px;
          span {
            font-size: 14px;
          }
        }
        .hanyu {
          font-size: 20px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #FFFFFF;
        }
      }
      .middle-box:nth-child(1) {
        background: #D8D8D8 linear-gradient(135deg, #2DC9EB 0%, #14D2B8 100%);
      }
      .middle-box:nth-child(2) {
        background: #D8D8D8 linear-gradient(314deg, #645AFF 0%, #A573FF 100%);
      }
      .middle-box:nth-child(3) {
        background: #D8D8D8 linear-gradient(153deg, #F15887 0%, #FE9B86 100%);
      }
      .middle-box:last-child {
        margin-right: 0px;
      }
    }
    .bottom {
      margin-top: 10px;
      width: 100%;
      height: 120px;
      .charts {
        width: 100%;
        height: 100%;
      }
    }
  }
}
</style>
